<template>
  <div class="notice">
      <h2>客服链接</h2>
      <div class="notice-cont" style="text-align: center;">
          <a-input v-model="content" style="width: 50%"/> 
      </div>
      <div class="btn-cont">
          <a-button type="primary" @click="save()">保存</a-button>
      </div>
  </div>
</template>

<script type="text/ecmascript-6">
import tinymce from "@/components/tinymce";
import api from '@/api/api.js'
export default {
  data() {
    return {
        aboutId: 4,
        content:''
    }
  },
  methods:{
    getAboutSystem(){
        api.getAboutSystem({aboutId:this.aboutId}).then(res=>{
            if(res.code==200){
                this.content=res.result.content;
            }
        });
    },
    save(){
        if(!this.content){
            this.$message.info('请输入内容再保存哦');
            return;
        }
        var param = new FormData();
        param.append('aboutId', this.aboutId);
        param.append('content', this.content);
        api.saveAboutSystem(param).then(res=>{
            if(res.code==200){
                this.$message.success(res.description);
                this.content=res.result.content;
            }else{
                this.$message.info(res.description)
            }
        });
    }
  },
  created(){
      this.getAboutSystem();
  },
  components: {tinymce}
}
</script>

<style scoped lang="scss">
.notice{
    h2{
        text-align: center;
        padding: 10px 0;
    }
    .notice-cont{
        width: 100%;
        overflow: hidden;
        box-sizing: border-box;
        padding: 0 10px;
    }
    .btn-cont{
        margin: 10px 0;
        text-align: center;
    }
}
</style>
